home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-12-20 | 1.9 KB | 98 lines | [TEXT/CWIE] |
- #include "ocheaders.h"
- #include "CBaseControl.h"
- #include "FnAssert.h"
- #include "BDAssert.h"
- #include "BDUtils.h"
-
- ///////////////////////////////////////////////////////////////////////////////
- //
- // Global functions
- //
-
- ///////////////////////////////////////////////////////////////////////////////
- //
- // GetObjectName
- //
-
- void GetObjectName (IUnknown* source, char * name)
- {
- assert(name != NULL);
-
- IControl* sourceObject = nil;
- char sourceName[Str255BufferLength];
-
- if (source)
- source->QueryInterface(IID_IControl, &sourceObject);
-
- if (sourceObject)
- {
- sourceObject->GetID(Str255StringLength, sourceName);
- strcpy((char *) name, sourceName);
- sourceObject->Release();
- }
- else
- {
- strcpy(name, "");
- }
- }
-
- ///////////////////////////////////////////////////////////////////////////////
- //
- // GetObjectID
- //
-
- void GetObjectID (IUnknown* source, char * id)
- {
- assert(id != NULL);
-
- IControl* sourceObject = nil;
- char sourceID[Str255BufferLength];
-
- if (source)
- source->QueryInterface(IID_IControl, &sourceObject);
-
- if (sourceObject)
- {
- sourceObject->GetID(Str255StringLength, sourceID);
- strcpy((char *) id, sourceID);
- sourceObject->Release();
- }
- else
- {
- strcpy(id, "");
- }
- }
-
- ///////////////////////////////////////////////////////////////////////////////
- //
- // LoadPropertyString
- //
-
- Boolean LoadPropertyString
- (IPropertyBag *pPropertyBag, char * propertyName, char * propertyValue, long maxLength, IErrorLog *pErrorLog)
- {
- VARIANT v;
- Boolean success = false;
- DWORD length;
-
- // VariantInit(&v);
-
- v.vt = VT_BSTR;
- v.bstrVal = NULL;
-
- pPropertyBag->Read(propertyName, &v, pErrorLog);
- if (v.bstrVal)
- {
- length = *((LPDWORD) v.bstrVal) ;
- if ( length < maxLength )
- strcpy(propertyValue, v.bstrVal + sizeof(DWORD));
- else
- strncpy(propertyValue, v.bstrVal + sizeof(DWORD), maxLength);
- CoTaskMemFree(v.bstrVal);
- // VariantInit(&v);
- success = true;
- }
-
- return success;
- }
-